---
title: v0.11.0
author: Doug Martin
author_title: Creator
author_url: https://github.com/doug-martin
author_image_url: https://avatars1.githubusercontent.com/u/361261?v=4
tags: [releases, minor]
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

### `@InjectQueryService`

In `v0.11.x` an new decorator was added `@InjectQueryService`, this decorator replaces the ORM specific decorators:
* `@InjectTypeOrmQueryService`
* `@InjectSequelizeQueryService`

To migrate replace all `@InjectTypeOrmQueryService` and `@InjectSequelizeQueryService` with `@InjectQueryService`.

:::note
You still need to import the `NestjsQueryTypeOrmModule` or `NestjsQuerySequelizeModule` to use `@InjectQueryService`.
:::

```ts
import { QueryService, InjectQueryService } from '@nestjs-query/core';
import { CRUDResolver } from '@nestjs-query/query-graphql';
import { Resolver } from '@nestjs/graphql';
import { TodoItemDTO } from './dto/todo-item.dto';
import { TodoItemEntity } from './todo-item.entity';

@Resolver(() => TodoItemDTO)
export class TodoItemResolver extends CRUDResolver(TodoItemDTO) {
  constructor(@InjectQueryService(TodoItemEntity) readonly service: QueryService<TodoItemEntity>) {
    super(service);
  }
}
```

## Relation Decorators

In `v0.11.x` two new decorators were introduced from the `@nestjs-query/query-graphql` package. The `@Relation` and `@Connection` allow specifying relations on the DTO rather than passing them in as options to the `CRUDResolver`.

### @Relation

The `@Relation` decorator allow specifying a single relation (e.g. one-to-one, many-to-one).

In this example we add a relation for a `todoItem`.

```ts {6}
import { FilterableField, Relation } from '@nestjs-query/query-graphql';
import { ObjectType, ID, GraphQLISODateTime } from '@nestjs/graphql';
import { TodoItemDTO } from '../todo-item/todo-item.dto.ts';

@ObjectType('SubTask')
@Relation('todoItem', () => TodoItemDTO, { disableRemove: true })
export class SubTaskDTO {
  @FilterableField(() => ID)
  id!: string;

  @FilterableField()
  title!: string;

  @FilterableField()
  completed!: boolean;

  @FilterableField(() => GraphQLISODateTime)
  created!: Date;

  @FilterableField(() => GraphQLISODateTime)
  updated!: Date;

  @FilterableField()
  todoItemId!: string;
}
```

### @Connection

The `@Connection` decorator allow specifying a connection relation (e.g. many-to-many, one-to-many).

In this example we add a connection for `subTasks`.

```ts {6}
import { FilterableField, Connection } from '@nestjs-query/query-graphql';
import { ObjectType, ID, GraphQLISODateTime } from '@nestjs/graphql';
import { SubTaskDTO } from '../sub-task/sub-task.dto'

@ObjectType('TodoItem')
@Connection('subTasks', () => SubTaskDTO, { disableRemove: true })
export class TodoItemDTO {
  @FilterableField(() => ID)
  id!: string;

  @FilterableField()
  title!: string;

  @FilterableField()
  completed!: boolean;

  @FilterableField(() => GraphQLISODateTime)
  created!: Date;

  @FilterableField(() => GraphQLISODateTime)
  updated!: Date;
}
```

## Auto Generated Resolvers

In `v0.11.x` the `@nestjs-query/query-graph` package is now able to automatically create your resolvers.

To start using this feature update your module to import the `NestjsQueryGraphQLModule`

:::note
When used with the new relation decorators, you can remove a lot of boiler plate.
:::

<Tabs
  defaultValue="typeorm"
  groupId="orm"
  values={[
    { label: 'TypeOrm', value: 'typeorm', },
    { label: 'Sequelize', value: 'sequelize', },
  ]
}>
<TabItem value="typeorm">

```ts title="todo-item.module.ts"
import { NestjsQueryGraphQLModule } from '@nestjs-query/query-graphql';
import { NestjsQueryTypeOrmModule } from '@nestjs-query/query-typeorm';
import { Module } from '@nestjs/common';
import { TodoItemDTO } from './todo-item.dto';
import { TodoItemEntity } from './todo-item.entity';

@Module({
  imports: [
    NestjsQueryGraphQLModule.forFeature({
      imports: [NestjsQueryTypeOrmModule.forFeature([TodoItemEntity])],
      resolvers: [{ DTOClass: TodoItemDTO, EntityClass: TodoItemEntity }],
    }),
  ],
})
export class TodoItemModule {}
```

</TabItem>
<TabItem value="sequelize">

```ts title="todo-item.module.ts"
import { NestjsQueryGraphQLModule } from '@nestjs-query/query-graphql';
import { NestjsQuerySequelizeModule } from '@nestjs-query/query-sequelize';
import { Module } from '@nestjs/common';
import { TodoItemDTO } from './todo-item.dto';
import { TodoItemEntity } from './todo-item.entity';

@Module({
  imports: [
    NestjsQueryGraphQLModule.forFeature({
      imports: [NestjsQuerySequelizeModule.forFeature([TodoItemEntity])],
      resolvers: [{ DTOClass: TodoItemDTO, EntityClass: TodoItemEntity }],
    }),
  ],
})
export class TodoItemModule {}
```

</TabItem>
</Tabs>

Once you have updated your module you can remove the old resolver.

:::note
Be sure to add the `NestjsQueryTypeOrmModule` or `NestjsQuerySequelizeModule` to the imports in `NestjsQueryGraphQLModule`.
:::

To read more about the auto-generated resolvers check out the [resolvers docs](/docs/graphql/resolvers)


### Example

#### Previously

```ts title="todo-item.resolver.ts"
import { QueryService, InjectQueryService } from '@nestjs-query/core';
import { CRUDResolver } from '@nestjs-query/query-graphql';
import { Resolver } from '@nestjs/graphql';
import { TodoItemInputDTO } from './todo-item.input';
import { TodoItemDTO } from './todo-item.dto';
import { TodoItemEntity } from './todo-item.entity';

@Resolver()
export class TodoItemResolver extends CRUDResolver(TodoItemDTO) {
  constructor(
      @InjectQueryService(TodoItemEntity) readonly service: QueryService<TodoItemEntity>
  ) {
    super(service);
  }
}
```

<Tabs
  defaultValue="typeorm"
  groupId="orm"
  values={[
    { label: 'TypeOrm', value: 'typeorm', },
    { label: 'Sequelize', value: 'sequelize', },
  ]
}>
<TabItem value="typeorm">

```ts title="todo-item.module.ts"
import { NestjsQueryTypeOrmModule } from '@nestjs-query/query-typeorm';
import { Module } from '@nestjs/common';
import { TodoItemEntity } from './todo-item.entity';
import { TodoItemResolver } from './todo-item.resolver';

@Module({
  providers: [TodoItemResolver],
  imports: [NestjsQueryTypeOrmModule.forFeature([TodoItemEntity])],
})
export class TodoItemModule {}

```

</TabItem>
<TabItem value="sequelize">

```ts title="todo-item.module.ts"
import { NestjsQuerySequelizeModule } from '@nestjs-query/query-sequelize';
import { Module } from '@nestjs/common';
import { TodoItemEntity } from './todo-item.entity';
import { TodoItemResolver } from './todo-item.resolver';

@Module({
  providers: [TodoItemResolver],
  imports: [NestjsQuerySequelizeModule.forFeature([TodoItemEntity])],
})
export class TodoItemModule {}

```

</TabItem>
</Tabs>


#### New

<Tabs
  defaultValue="typeorm"
  groupId="orm"
  values={[
    { label: 'TypeOrm', value: 'typeorm', },
    { label: 'Sequelize', value: 'sequelize', },
  ]
}>
<TabItem value="typeorm">

```ts title="todo-item.module.ts"
import { NestjsQueryGraphQLModule } from '@nestjs-query/query-graphql';
import { NestjsQueryTypeOrmModule } from '@nestjs-query/query-typeorm';
import { Module } from '@nestjs/common';
import { TodoItemDTO } from './todo-item.dto';
import { TodoItemEntity } from './todo-item.entity';

@Module({
  imports: [
    NestjsQueryGraphQLModule.forFeature({
      imports: [NestjsQueryTypeOrmModule.forFeature([TodoItemEntity])],
      resolvers: [{ DTOClass: TodoItemDTO, EntityClass: TodoItemEntity }],
    }),
  ],
})
export class TodoItemModule {}
```

</TabItem>
<TabItem value="sequelize">

```ts title="todo-item.module.ts"
import { NestjsQueryGraphQLModule } from '@nestjs-query/query-graphql';
import { NestjsQuerySequelizeModule } from '@nestjs-query/query-sequelize';
import { Module } from '@nestjs/common';
import { TodoItemDTO } from './todo-item.dto';
import { TodoItemEntity } from './todo-item.entity';

@Module({
  imports: [
    NestjsQueryGraphQLModule.forFeature({
      imports: [NestjsQuerySequelizeModule.forFeature([TodoItemEntity])],
      resolvers: [{ DTOClass: TodoItemDTO, EntityClass: TodoItemEntity }],
    }),
  ],
})
export class TodoItemModule {}
```

</TabItem>
</Tabs>


